<script setup>
import { onLaunch, onShow } from '@dcloudio/uni-app'
import { AppInit } from './sheep'
import { getUrlParam } from './sheep/utils/helper.js'
import { watch, watchEffect } from 'vue'
import $ from '@/sheep'
const useUser = $.store('user')
// import { isH5Dev } from '@/sheep/utils/is.js'
// if (isH5Dev()) {
//   const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJqd3RfeWgiLCJleHAiOjE3MzE1NjM5OTcsInN1YiI6IllIIiwiYXVkIjoiZXZlcnkiLCJuYmYiOjE3MDAwMjc5OTcsImlhdCI6MTcwMDAyNzk5NywianRpIjoxMDAwMSwidWlkIjoxfQ.abZDLUUt7pe9JGnDJL5y3BEvuE5u64c9i4mTEZIh4UU'
//   uni.setStorageSync('token', token)
// }

onLaunch(async(options) => {
  // 加载Shopro底层依赖
  AppInit()
  setDebug()
})

onShow(() => {

})

watch(() => useUser.isLogin, async val => {
  if (!val) {
    return
  }
  const a_id = $.utils.getUrlParam('aId') || undefined
  const p_id = $.utils.getUrlParam('pid', '')
  if (!p_id) {
    return
  }
  const data = { p_id, a_id }
  $.post('/dg/ban', data).then(() => {}, () => {})
}, { immediate: true })

function setDebug() {
  if (getUrlParam('bug')) {
    var script = window.document.createElement('SCRIPT')
    script.src = 'https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js'
    script.onload = function() {
      window.vConsole = new window.VConsole({
        maxLogNumber: 1000,
        // disableLogScrolling: true,
        onReady: function() {
          console.log('vConsole is ready.')
        },
        onClearLog: function() {
          console.log('on clearLog')
        }
      })
    }
    document.documentElement.appendChild(script)
  }
}
</script>

<style lang="scss">
	/* 引入iconfont字体图标 */
	@import '@/static/iconfont/iconfont.css';
	/* 引入uv-ui的公共样式 */
	@import '@/uni_modules/uv-ui-tools/index.scss';
	/* 每个页面公共css */
	@import '@/static/css/index.scss';

	html, body {
		// max-width: 750rpx;
		margin: 0 auto;
	}

	body, page {
		font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,SimSun,sans-serif;
		color: $uv-main-color;
		font-size: 28rpx;
		height: 100%;
		line-height: 1.4;
		width: 100%;
		word-break: break-all; //英文文本不换行
		white-space: normal;
		margin: 0 auto;
		background-color: $u-bg-color;
		-webkit-overflow-scrolling: touch; // 解决ios滑动不流畅
	}
	.page-body {
		::v-deep .uv-button {
			&.uv-button--normal {
				height: 38px;
			}
			&.uv-button--large {
				font-size: 16px;
				height: 46px;
				padding: 0 20px;
			}
		}
	}

</style>
